Skip to content

feat(worker): split agent git auth from publication write auth (#4) - #37

Merged
BunsDev merged 4 commits into
mainfrom
feat/issue-4-token-scope-split
Jul 6, 2026
Merged

feat(worker): split agent git auth from publication write auth (#4)#37
BunsDev merged 4 commits into
mainfrom
feat/issue-4-token-scope-split

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 6, 2026

Copy link
Copy Markdown
Member

Closes #4.

  • Installation tokens are now minted per role, scoped to the single target repository: orchestration (contents:read, checks:write, issues:write, pull_requests:read) held by the adapter for refs, Check Runs, and progress comments; agent git (contents:write only) injected via COVEN_GIT_TOKEN; and publication (pull_requests:write, issues:write, contents:read) minted only after the result envelope passes contract validation.
  • New redact module scrubs live token values and GitHub token patterns from every free-text result field before the task store, comments, PR bodies, or Check Run output see them; error strings embedded in published surfaces are redacted too.
  • The worker refuses to write a session brief containing a live token (belt-and-braces on the existing serialization guard; deliberately exact-match only, so user-authored issue text quoting a token-shaped string cannot veto task execution).
  • wiremock integration test proves per-endpoint token routing (PR opened with the publication token, check updates with orchestration, agent receives exactly the agent-git token) and zero token leakage in outgoing payloads.
  • Not in scope (locked contract v2 §5.3 — the runtime pushes its own branch): a fully read-only agent token. That requires adapter-side branch push, i.e. contract v3 coordinated with coven-code (#97/#100/#102/#109). Documented as a remaining hardening target in docs/security.md; docs/headless-contract.md §1.1 gains a non-breaking clarification that COVEN_GIT_TOKEN is contents:write on the target repo only.

Plan and grooming trail: #4 (comment)

🤖 Generated with Claude Code

BunsDev added 4 commits July 6, 2026 15:55
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
…hases (#4)

Installation tokens are now minted per role and constrained to the single
target repository: orchestration (contents:read, checks:write, issues:write,
pull_requests:read) held by the adapter; agent git (contents:write only)
injected via COVEN_GIT_TOKEN; publication (pull_requests:write, issues:write)
minted only after the result envelope passes contract validation. The result
envelope is sanitized before any persistence or publication, and the worker
refuses to write a session brief containing a live token.

Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Copilot AI review requested due to automatic review settings July 6, 2026 21:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens the worker’s security boundary by separating GitHub App installation tokens by phase/role and ensuring token redaction occurs before anything is persisted or published back to GitHub. It fits the adapter’s responsibility to strictly control publication authority while keeping the agent constrained to the minimum required Git capability.

Changes:

  • Introduces role-scoped installation token minting (orchestration vs agent git vs publication) and mints publication authority only post-result validation.
  • Adds a centralized redaction/sanitization module to scrub live token values and token-shaped patterns from all free-text result fields and surfaced error strings.
  • Adds an integration-style wiremock test to assert per-endpoint token routing and prevent token leakage in outgoing payloads.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
docs/security.md Documents the new three-token role split and the redaction guarantees/hardening targets.
docs/headless-contract.md Clarifies the scoped permission set for COVEN_GIT_TOKEN within contract v2.
crates/worker/src/redact.rs Adds token scanning/redaction and result sanitization helpers with unit tests.
crates/worker/src/lib.rs Splits token minting by role, injects only agent-git token into the child process, sanitizes results pre-publication, and adds a wiremock test for routing/leak prevention.
crates/worker/Cargo.toml Adds wiremock as a dev dependency for worker tests.
crates/github/src/installation.rs Adds TokenRole and scoped token minting that constrains permissions to a single repo + phase-specific permission sets.
Cargo.toml Adds workspace dependency version for wiremock.
Cargo.lock Locks new transitive dependencies introduced by wiremock.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/headless-contract.md
artifact. The 1-hour token TTL is the adapter's concern; the runtime treats the
token as opaque and valid for the session.

The adapter scopes this token to `contents: write` on the target repository
@BunsDev
BunsDev merged commit e6304e7 into main Jul 6, 2026
2 checks passed
@BunsDev
BunsDev deleted the feat/issue-4-token-scope-split branch July 6, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split agent read auth from publication write auth

2 participants